<template>
    <div id="seachDialog">
      <a-modal
      title="快速筛选"
      width="550px"
      :visible="searchData.show"
      @cancel="handleClose">
        <el-row style="padding:30px 70px 50px 20px;overflow-y:auto;overflow-x:hidden;">
            <el-form :model="searchParames" ref="searchParames" label-width="120px">
                <el-form-item label="公司名称:">
                    <el-input clearable size="small" v-model="searchParames.customerName" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="合同流水号:">
                    <el-input clearable size="small" v-model="searchParames.contractId" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="退款编号:">
                    <el-input clearable size="small" v-model="searchParames.refundNumber" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="审核状态:">
                    <el-select clearable style="width:180px" size="small"  v-model="searchParames.refundStatus" placeholder="审核状态">
                        <el-option label="已确认" value="CONFIRMED"></el-option>
                        <el-option label="待确认" value="UNCONFIRMED"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="申请时间:">
                    <el-date-picker
                    style="width:100%"
                    size="small"
                    clearable
                    value-format="yyyy-MM-dd"
                    v-model="searchParames.createDate"
                    type="date"
                    placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
            </el-form>
        </el-row>
        <span slot="footer" class="dialog-footer">
            <el-button size="small" @click="handleReset">重置</el-button>
            <el-button size="small" type="primary" @click="handleSend">查询</el-button>
        </span>
      </a-modal>
    </div>
</template>

<script>
export default {
    props: ['searchData'],
    data() {
        return {
          searchParames: {
            customerName: '',
            contractId: '',
            refundNumber: '',
            refundStatus: '',
            createDate: ''
          },
        };
    },
    methods: {
        handleSend () {
            let searchDate = []
            for(var key in this.searchParames){
                if (this.searchParames[key]) {
                    if (key == 'createDate') {
                        searchDate.push({
                            key: key,
                            value: this.searchParames[key],
                            type: 'date'
                        })
                    } else if (key == 'refundStatus') {
                        searchDate.push({
                            key: key,
                            value: this.searchParames[key],
                            type: 'enumeration'
                        })
                    } else {
                        searchDate.push({
                            key: key,
                            value: this.searchParames[key],
                            type: 'string'
                        })
                    }
                }
            }
            this.$emit('checkSearch',searchDate)
            this.handleClose()
        },
        checkValue (value) { //来源获取信息
            this.searchParames.contractSourceType = value
        },
        handleClose () {
            this.searchData.show = false
        },
        handleReset () {
            this.searchParames.customerName = ''
            this.searchParames.contractId = ''
            this.searchParames.refundNumber = ''
            this.searchParames.refundStatus = ''
            this.searchParames.createDate = ''
            this.$emit('resetSearch')
            this.$refs.searchParames.resetFields()
        }
    },
    computed: {
      changeDialog () {
        return this.searchData.show
      }
    }, 
    watch: {
      changeDialog: {
        handler (curVal, oldVal) {
          if (curVal) {
            this.searchParames.customerName = this.searchData.customerName
          } else {
          }
        }
      }
    },
};
</script>

<style>
#seachDialog .el-dialog{
    padding-bottom: 0; 
    overflow-x: hidden;
}
#seachDialog .el-dialog__footer{
    border-top: #f4f4f4 solid 1px;
}
.ant-modal-body{
    padding: 0
}
</style>
